/*
 * Module 02
 *
 */

package ua.gl.basecamp.tabachnyy.testcase;

import java.util.Collections;
import java.util.List;

/**
 * @author yaroslav.tabachnyy@gmail.com
 * @version 1.02
 * @date 14.02.2013
 *
 */
public abstract class Question {

    private String stringRepresentation;
    private List<Answer> answers;

    public Question(String stringRepresentation, List<Answer> answers) {
        this.stringRepresentation = stringRepresentation;
        this.answers = answers;
    }

    public abstract double getAnswersScore(List<UserAnswer> userAnswers);
    public abstract List<UserAnswer> getAnswersFromString(String userAnswersString);
    @Override
    public abstract String toString();

    public List<Answer> getAnswers() {
        return answers;
    }

    public Answer getAnswer(int number) {
        return answers.get(number);
    }

    public String getStringRepresentation() {
        return  stringRepresentation;
    }

    public String getAnswersString() {

        String answersString = "";
        int maxAnswersSize = answers.size();
        String formatLineString = "%d. %s \n";
        for (int index = 0; index < maxAnswersSize; index++) {
            answersString +=
                    String.format(formatLineString, (index + 1), answers.get(index));
        }
        return answersString;
    }

    public void shuffleAnswers() {
        Collections.shuffle(answers);
    }
}
